package com.perfma.xtest.tool;


import cn.hutool.crypto.digest.MD5;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.DigestUtils;
import sun.misc.BASE64Encoder;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Random;

/**
 * @author: junhui.si
 * @date: 2023-02-07 17:48
 **/
public class Partition {
    public static void main(String[] args) throws UnsupportedEncodingException, NoSuchAlgorithmException, MalformedURLException {
//        List<Integer> nonExistIps = Lists.newArrayList(1,2,3);
//        List<List<Integer>> nonExistIpsTemp = Lists.partition(nonExistIps, 2);
//        System.out.println(nonExistIpsTemp);

//        String data = "{\"username\":\"Tom\",\"email\":\"tom@gmail.com\"}";
//        BASE64Encoder encoder = new BASE64Encoder();
//        byte[] md5 = DigestUtils.md5Digest(data.getBytes(StandardCharsets.UTF_8));
//        String encodedText = encoder.encode(md5);
//        System.out.println(encodedText);
//        MessageDigest md5 = MessageDigest.getInstance("MD5");
//        md5.update(data.getBytes(StandardCharsets.UTF_8));
//        System.out.println(new String(md5.digest()));
//        Random random = new Random();
//        for (int i = 0; i < 20; i++) {
//            System.out.println(random.nextInt(10000));
//        }

//        System.out.println((5211346162783748096L >> 16) & 15);
//        String fileName = "/data/Path/data.txt";
//        System.out.println(StringUtils.isEmpty(fileName) ? fileName : StringUtils.substringAfterLast(fileName, File.separator));
        URL url = new URL("http://xx.com/api/xsea/xxx/123");
        System.out.println(url.getPath());
        System.out.println(url.getProtocol());
    }
}
